package com.game.server.message.proto.execute;

import com.comm.ISession;

import com.game.majiang.logic.LogicClient;
import com.game.majiang.logic.LogicServer;
import com.game.majiang.logic.LogicTable;
import com.game.server.message.proto.in.AbstractRoomMasterOperateReq;
import com.game.server.message.proto.out.RoomMasterOperateRsp;
import com.game.server.system.AbstractTable;

public class RoomMasterOperateReq extends AbstractRoomMasterOperateReq {

    @Override
    public void Execute(ISession session) {
        LogicClient client = (LogicClient) LogicServer.getInstance().getClient(session.getId());

		System.out.println("收到房间解散消息");
        if (client != null&&client.checkClick(msgcode)) {
            AbstractTable abTable = client.getTable();

            if(abTable != null) {
            	RoomMasterOperateRsp rsp = new RoomMasterOperateRsp();
    			rsp.setIsok(1);
    			rsp.setTempid(0);
    			rsp.setType(this.type);
				System.out.println("收到房间解散消息this.type:"+this.type);
            	LogicTable table = (LogicTable) abTable;
            	boolean succBool = false;
            	if(this.type == 0) {
            		succBool = table.bankerCloseRoom(client);
        		} else if(this.type == 1) {
        			succBool = table.bankerCloseChat(client, this.tempid);
        		} else if(this.type == 2) {
        			succBool = table.bankerKickPeople(client, this.tempid);
        		} else if(this.type == 3) {
        			succBool = table.bankerKickStandup(client, this.tempid);
        		}

            	if(!succBool) {
            		client.Send(rsp);
            	}
            }
        }
    }

}
